Conditions | 2 |
Total Lines | 11 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { localizedField, localizedFieldNonNull } from "../models/app"; |
||
36 | |||
37 | export function matchValueToModel<T>( |
||
38 | locale: Locales, |
||
39 | field: TranslatableKeys<T>, |
||
40 | value: string, |
||
41 | possibilities: T[], |
||
42 | ): T | null { |
||
43 | const matching = possibilities.filter( |
||
44 | (model) => localizeField(locale, model, field) === value, |
||
45 | ); |
||
46 | return matching.length > 0 ? matching[0] : null; |
||
47 | } |
||
48 |